//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using ProjectBase.Core;
using ProjectBase.Core.Service;
using ProjectBase.Core.Tools.Export;
using ProjectBase.Mvc;

using $prjsn$.Common;
using $prjsn$.Common.Business.Services;
using $prjsn$.Entity.Services;

namespace $safeprojectname$.Tools.Export.Excel
{
    /// <summary>
    /// Basic tests for Language
    /// </summary>
    [TestClass]
    public class ExportLanguageTest : EntityTestBase<ILangFacade>
    {
        [TestMethod]
        public void CreateLanguage()
        {
            var langs = Facade.GetAll();
            IEnumerable<IEnumerable<IExCell>> entities = langs
                .Select(i => new List<IExCell>
                {
                    new ExCell
                    {
                        Name = "Language",
                        Type = ExCellType.String,
                        Value = i.LanguageName
                    },
                    new ExCell
                    {
                        Name = "ID",
                        Type = ExCellType.Number,
                        Value = i.ID
                    },
                    new ExCell
                    {
                        Name = "Now",
                        Type = ExCellType.DateTime,
                        Value = DateTime.Now
                    },
                });

            var exporter = ProjectBase.Core.Service.Factory.CreateInstance<IExcelExporter>();
            var model = ProjectBase.Core.Service.Factory.CreateInstance<IExcelExporterData>();

            if (exporter.IsNull() || model.IsNull())
            {
                Assert.Inconclusive("there is no Excel Exporter (IExcelExporter or IExcelExporterData implementation");
            }

            model.Entities = entities;
            var success = exporter.Execute(model);

            Assert.IsFalse(Messages.ContainsError(), Messages.GetErrorMessage());
            Assert.IsTrue(success, "export was not successful");

            Assert.IsTrue(model.OutputData.IsNotEmpty(), "Empty result, no exported file");
        }

        #region Additional test attributes
        // constructor
        [ClassInitialize]
        public static void MyClassInitialize(TestContext testContext) { }

        [ClassCleanup]
        public static void MyClassCleanup() { }

        [TestInitialize]
        public override void MyTestInitialize() { base.MyTestInitialize(); }

        [TestCleanup]
        public override void MyTestCleanup() { base.MyTestCleanup(); }
        #endregion Additional test attributes
    }
}